#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
    File Name:      Singleton
    Author:         'daze'
    date:           2018/12/14

    子类通过 hasattr(Test, '_instance') 判断是否有实例，防止 __init__() 走两次
"""


class Singleton(object):
    def __new__(cls, *args, **kw):
        if not hasattr(cls, '_instance'):
            orig = super(Singleton, cls)
            cls._instance = orig.__new__(cls, *args, **kw)
        return cls._instance
